package com.tql.pandian.controller;

import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.tql.pandian.entity.*;
import com.tql.pandian.vo.TqlStapProlossVO;
import com.tql.pandian.service.TqlStapProlossService;
import com.tql.pandian.vo.TopCateStapProlossRecordVO;
import com.tql.pandian.vo.TopCateStapProlossVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * @author zhengcl
 * @since 1.0.0
 */
@RestController
@RequestMapping("/stapproloss")
@Api(tags = "损益分析")
public class TqlStapProlossController extends BaseController {

    @Autowired
    private TqlStapProlossService tqlStapProlossService;

    @GetMapping("/topcate/page")
    @ApiOperation("顶级类别列表损益分析")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
        @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "deptCode", value = "deptCode", paramType = "query", dataType = "string")
    })
    public AjaxResult topCatePage(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TopCateStapProlossVO> voList = tqlStapProlossService.selectTopcatePage(params);
        return success(voList);
    }

    @GetMapping("/topcate/dept")
    @ApiOperation("某顶级类各部门损益分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string")
    })
    public AjaxResult topCateDeptPage(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TopCateStapProlossVO> dataList = tqlStapProlossService.selectTopcateDeptPage(params);
        return success(dataList);
    }

    @GetMapping("/page")
    @ApiOperation("某顶级类物料列表损益分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapTypeCode", value = "物料类别", paramType = "query", dataType = "string")
    })
    public AjaxResult stapPage(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TopCateStapProlossVO> dataList = tqlStapProlossService.selectPage(params);
        return success(dataList);
    }

    @GetMapping("/dept/page")
    @ApiOperation("各部门该物料损益分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapTypeCode", value = "物料类别", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapCode", value = "物料类别", paramType = "query", dataType = "string"),
    })
    public AjaxResult deptStapPage(@ApiIgnore @RequestParam Map<String, Object> params) {


      List<TopCateStapProlossVO> dataList = tqlStapProlossService.selectDeptStapPage(params);
        return success(dataList);
    }

    @GetMapping("/spu/deptPage/{id}")
    @ApiOperation("某物料spu各部门用料sku明细")

    public AjaxResult spuDeptPage(@PathVariable("id") String id) {
        Long idl=Long.parseLong(id);
        TqlStapProloss data = tqlStapProlossService.selectSpuDeptPage(idl);
        return success(data);
    }


    @GetMapping("/dept/cate/page")
    @ApiOperation("某部门某类的物料spu损益分析（业务逻辑待确定")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "deptCode", value = "部门CODE", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapTypeCode", value = "物料类别", paramType = "query", dataType = "string"),
    })
    public AjaxResult deptCatePage(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TopCateStapProlossVO> dataList = tqlStapProlossService.selectdeptCatePage(params);
        return success(dataList);
    }

    @GetMapping("/dept/allpage")
    @ApiOperation("部门列表损益分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "shopCode", value = "门店shopCode", paramType = "query", dataType = "string"),
    })
    public AjaxResult deptPage(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TopCateStapProlossVO> dataList = tqlStapProlossService.deptPage(params);
        return success(dataList);
    }

    @GetMapping("/info")
    @ApiOperation("该部门该物料sku盘点及核算表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "deptCode", value = "部门deptCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapCode", value = "物料类别", paramType = "query", dataType = "string"),
    })
    public AjaxResult info(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TqlStapProlossItem> data = tqlStapProlossService.info(params);
        return success(data);
    }

    @GetMapping("/infoDetial")
    @ApiOperation("该部门该物料sku盘点及核算表(new)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "deptCode", value = "部门deptCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapCode", value = "物料类别", paramType = "query", dataType = "string"),
    })
    public AjaxResult infoDetial(@ApiIgnore @RequestParam Map<String, Object> params) {
        ProlossDetialDto data = tqlStapProlossService.infoDetial(params);
        return success(data);
    }

    @GetMapping("/infoItem")
    @ApiOperation("该部门该物料sku盘点及核算表[实际]")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "deptCode", value = "部门deptCode", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "stapCode", value = "物料类别", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "type", value = "[0：实际，1：核算]", paramType = "query", dataType = "string"),
    })
    public AjaxResult infoItem(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TqlStapProlossItem> data = tqlStapProlossService.infoItem(params);
        return success(data);
    }

    @GetMapping("/diagnosis")
    @ApiOperation("用料实盘诊断")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string")
    })
    public AjaxResult diagnosis(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TqlStapProlossDiagnosis> data = tqlStapProlossService.diagnosis(params);
        return success(data);
    }

    @GetMapping("/diagnosis/info")
    @ApiOperation("用料实盘诊断详情")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pandianCode", value  = "pandianCode", paramType = "query", dataType = "string")
    })
    public AjaxResult diagnosisInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
        List<TqlStapProlossDiagnosisInfo> data = tqlStapProlossService.diagnosisInfo(params);
        return success(data);
    }







}
